<?php
defined('_JEXEC') or die('Restricted access');

$jversion = new JVersion();
$j15 = ($jversion->RELEASE == '1.5');
if ($j15 == true) {
  JToolBarHelper::title(JText::_('NS Pro Mailing List Manager'), 'massemail.png');
}
else {
  JToolBarHelper::title(JText::_('NS Pro Mailing List Manager'), 'groups.png');
}

jimport('joomla.application.component.helper');
$params = JComponentHelper::getParams( 'com_nspro' );
if ($j15 == true) {
  $component = JComponentHelper::getComponent( 'com_nspro' );
  $params = new JParameter( $component->params );
}

$db =& JFactory::getDBO();

?>

<form id="adminForm" action="<?php echo JRoute::_( 'index.php' );?>" method="post" name="adminForm">
<div id="editcell">
    <table class="adminlist">
    <thead>
        <tr>
            <th width="5">
                <?php echo JHTML::_( 'grid.sort', JText::_('ID'), 'id', $this->olists['order_Dir'], $this->olists['order']); ?>
            </th>
            <th width="20">
                <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->lists ); ?>);" />
            </th>
            <th class="title">
                <?php echo JHTML::_( 'grid.sort', JText::_('Name'), 'lname', $this->olists['order_Dir'], $this->olists['order']); ?>
            </th>
            <th width="100">
                <?php echo JHTML::_( 'grid.sort', JText::_('Published'), 'published', $this->olists['order_Dir'], $this->olists['order']); ?>
            </th>
            <th width="80">
              <?php print JText::_('Subscriptions'); ?>
            </th>
            <th width="40%" class="notes">
                <?php echo JText::_( 'Notes' ); ?>
            </th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <td colspan="8">
                <?php
                  print $this->pagination->getListFooter();
                ?>
            </td>
        </tr>
    </tfoot>
    <tbody>
    <?php
    $k = 0;
    for ($i=0, $n=count( $this->lists ); $i < $n; $i++)
    {
        $row = &$this->lists[$i];
        $row->checked_out = false;
        $checked    = JHTML::_('grid.checkedout', $row, $i );
        $link       = JRoute::_( 'index.php?option=com_nspro&controller=nspro&task=ledit&cid[]='. $row->id );
        $published  = JHTML::_('grid.published', $row, $i );

        $query = 'SELECT COUNT(`id`) FROM `#__nspro_subs` WHERE (`confirmed` = 1) AND (FIND_IN_SET("' . $row->id . '", `mailing_lists`) > 0)';
        $db->setQuery( $query );
        $sCount = $db->loadResult();

        ?>
        <tr class="<?php echo "row$k"; ?>">
            <td>
                <?php echo $row->id; ?>
            </td>
            <td>
                <?php echo $checked; ?>
            </td>
            <td>
                <a href="<?php echo $link; ?>"><?php echo $row->lname; ?></a>
            </td>
            <td align="center">
              <?php print $published; ?>
            </td>
            <td align="center">
              <?php print $sCount; ?>
            </td>
            <td>
                <?php echo $row->notes; ?>
            </td>
        </tr>
        <?php
        $k = 1 - $k;
    }
    ?>
    </tbody>
    </table>

<input type="hidden" name="option" value="com_nspro" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="controller" value="nspro" />
<input type="hidden" name="filter_order" value="<?php echo $this->olists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->olists['order_Dir']; ?>" />
</form>
<br/>
<center><small><i>NS Pro by <a href="http://www.mavrosxristoforos.com/">Mavrosxristoforos.com</a> Copyright 2009-2011</i></small></center>
</div>
